package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xmy.cultivate.entity.SkillStationsItems;
import com.xmy.cultivate.entity.SkillStationsTeacher;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 岗位老师 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2025-08-21
 */
public interface SkillStationsTeacherMapper extends BaseMapper<SkillStationsTeacher> {


    @Select({
            "<script>",
            "SELECT" ,
                "t1.*," ,
                "t2.name AS stations_name," ,
                "getSubjectsName(t1.subjects_id) AS subjects_name," ,
                "getStaffNameForId(t1.teacher_id) AS teacher_name" ,
                "FROM" ,
                "skill_stations_teacher AS t1" ,
                "LEFT JOIN skill_stations AS t2 ON t1.stations_id = t2.id" ,
            "WHERE 1=1" ,
            "<if test='yearPart !=null and yearPart != &apos;&apos;'>" ,
            "AND t1.year_part = ${yearPart}" ,
            "</if>" ,
            "<if test='quarterNum !=null and quarterNum != &apos;&apos;'>" ,
            "AND t1.quarter_num = ${quarterNum}" ,
            "</if>" ,
            "<if test='departmentId !=null and departmentId != &apos;&apos;'>" ,
            "AND t1.department_id = ${departmentId}" ,
            "</if>" ,

            "<if test='type !=null and type != &apos;&apos;'>" ,
            "AND t1.type = ${type}" ,
            "</if>" ,
            "<if test='stationsId !=null and stationsId != &apos;&apos;'>" ,
            "AND t1.stations_id = ${stationsId}" ,
            "</if>" ,
            "<if test='subjectsId !=null and subjectsId != &apos;&apos;'>" ,
            "AND t1.subjects_id = ${subjectsId}" ,
            "</if>" ,
            "ORDER BY t1.created_at" ,

            "</script>"
    })
    public IPage<SkillStationsTeacher> findAll(
            IPage<?> iPage,
            @Param("yearPart") String yearPart,
            @Param("quarterNum") String quarterNum,
            @Param("departmentId") String departmentId,
            @Param("type") String type,
            @Param("stationsId") String stationsId,
            @Param("teacherName") String teacherName,
            @Param("subjectsId") String subjectsId);

}
